<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>拖拽</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      #div1 {
        width: 100px;
        height: 100px;
        background: red;
        position: absolute;
        left: 0;
        top: 0;
      }
      #div2 {
        width: 100px;
        height: 100px;
        background: rgb(0, 255, 34);
        position: absolute;
        left: 0;
        top: 150px;
      }
    </style>
    <script src="../js/tool.js"></script>
    <script>
      window.onload = function () {
        new Drag("div1");
        new LimitDrag("div2");
      };
    </script>
  </head>
  <body>
    <div id="div1"></div>
    <div id="div2"></div>
  </body>
</html>
